define(['jquery','layui'], function ($,layui) {
    //layuiadmin组件要用到的
    layui.config({
        base: '/assets/libs/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index','console']);

    //获取我的任务
    function getTask() {
        $.post("mytask/dashMytask", {
        }, function (res) {
            let data = res.data;
            let html = '';
            if (data.length > 0) {
                for (let i = 0; i < data.length; i++) {
                    html += '<tr>';
                    html += '<td>' + data[i]["title"] + '</td>';
                    html += '<td>' + data[i]["admin_id_text"] + '</td>';
                    html += '<td>' + data[i]["project_ids_text"] + '</td>';
                    html += '<td>' + data[i]["state_text"] + '</td>';
                    html += '<td>' + data[i]["createtime_text"] + '</td>';
                    html += '</tr>';
                }
            }
            $('#task').html(html);
        });
    }
    getTask();

    //获取我的计划
    function getPlan() {
        $.post("plan/dashMyPlan", {
        }, function (res) {
            let data = res.data;
            let html = '';
            if (data.length > 0) {
                for (let i = 0; i < data.length; i++) {
                    html += '<tr>';
                    html += '<td>' + data[i]["title"] + '</td>';
                    html += '<td>' + data[i]["status_text"] + '</td>';
                    html += '<td>' + data[i]["project_id_text"] + '</td>';
                    html += '<td>' + data[i]["startime_text"] + '</td>';
                    html += '</tr>';
                }
            }
            $('#my-plan-info').html(html);
        });
    }
    getPlan();

    //获取我的日志
    function getRecord() {
        $.post("record/dashMyRecord", {
        }, function (res) {
            let data = res.data;
            let html = '';
            if (data.length > 0) {
                for (let i = 0; i < data.length; i++) {
                    html += '<tr>';
                    html += '<td>' + data[i]["title"] + '</td>';
                    html += '<td>' + data[i]["plan_id_text"] + '</td>';
                    html += '<td>' + data[i]["createtime_text"] + '</td>';
                    html += '</tr>';
                }
            }
            $('#my-record-info').html(html);
        });
    }
    getRecord();

    //获取通知
    function getNotice() {
        $.post("article/article/dashNotice", {
        }, function (res) {
            let data = res.data;
            let html = '';
            if (data.length > 0) {
                for (let i = 0; i < data.length; i++) {
                    html += '<tr>';
                    html += '<td><a href="dashboard/detail?cid=' + data[i]["category_id"] + '&ids=' + data[i]["id"] + '">' + data[i]["title"] + '</a></td>';
                    html += '<td>' + data[i]["createtime_text"] + '</td>';
                    html += '</tr>';
                }
            }
            $('#notice').html(html);
        });
    }
    getNotice();
})
